﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConfigCreate
{
    /// <summary>
    /// 设置控件的绑定模式和状态
    /// </summary>
    [AttributeUsage(AttributeTargets.Property, AllowMultiple = false)]
    public class CreateBindingPanelAttribute : Attribute
    {
        /// <summary>
        /// 设置控件的绑定模式和状态
        /// </summary>
        /// <param name="binding_data_property_name">设置控件弹出绑定框的数据源\n支持Func&lt;object, GroupHeader, List&lt;BindingData&gt;&gt; 类型属性\n和 List&lt;BindingData&gt;'类型属性</param>
        /// <exception cref="ConfigException"></exception>
        public CreateBindingPanelAttribute(string binding_data_property_name)
        {
            if (string.IsNullOrWhiteSpace(binding_data_property_name))
                throw new ConfigException("设置绑定属性必须设置绑定数据源属性名“BindingDataPropertyName”");
            BindingDataPropertyName = binding_data_property_name;
        }

        /// <summary>
        /// 设置控件弹出绑定框的数据源
        /// 支持Func&lt;object, GroupHeader, List&lt;BindingData&gt;&gt; 类型属性
        /// 和 List&lt;BindingData&gt;类型属性
        /// </summary>
        public string BindingDataPropertyName { get; set; }

        /// <summary>
        /// 默认模式是否为绑定模式
        /// </summary>
        public bool DefaultBinding { get; set; } = true;
        /// <summary>
        /// 是否显示模式切换按钮
        /// </summary>
        public bool ShowSwitchButton { get; set; } = true;
    }
}
